<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>元素垂直居中</title>
    <style>
        .container{
            position: fixed;
            top:0;
            right:0;
            bottom:0;
            left:0;
            background:rgba(0,0,0,.4);
            text-align: center;
            font-size: 0;
        }
        .dialog{
            background-color: #fff;
            height:30%;
            display:inline-block;
            vertical-align: middle;
            width:200px;
            text-align: left;
            font-size: 14px;
        }
        .container:after{
            content: "x";
            display: inline-block;
            height: 100%;
            width: 12px;
            vertical-align: middle;
            color: #000;
            font-size: 12px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="dialog">内容</div>
    </div>
</body>
</html>